﻿using System;
using System.Collections.Generic;
using System.Text;

using OgilvyOne.UKNow.Common;
using OgilvyOne.UKNow.Model;

namespace OgilvyOne.UKNow.Globalization
{
    public class EnglishLanguage : ILanguage
    {
        public LanguageType LanguageType { get { return LanguageType.en; } }

        public string GetModelText(Type modelType)
        {
            string typeText = null;

            if (modelType.Equals(typeof(ArtFormModel)))
                typeText = "Art form";
            else if (modelType.Equals(typeof(EventsCommentModel)))
                typeText = "Events comment";
            else if (modelType.Equals(typeof(EventsImageModel)))
                typeText = "Events image";
            else if (modelType.Equals(typeof(EventsInterviewVideoModel)))
                typeText = "Events interview video";
            else if (modelType.Equals(typeof(EventsModel)))
                typeText = "Events";
            else if (modelType.Equals(typeof(EventsVideoModel)))
                typeText = "Events video";
            else if (modelType.Equals(typeof(MemberModel)))
                typeText = "Member";
            else if (modelType.Equals(typeof(NewsModel)))
                typeText = "News";
            else if (modelType.Equals(typeof(SponsorModel)))
                typeText = "Sponsor";
            else if (modelType.Equals(typeof(WarmupCommentModel)))
                typeText = "Warmup comment";
            else if (modelType.Equals(typeof(WarmupModel)))
                typeText = "Warmup";
            else if (modelType.Equals(typeof(EventsLogModel)))
                typeText = "Events log";
            else
                typeText = "Undefined model type";

            return typeText;
        }

        public string GetActionText(Enums.Action action)
        {
            string text = null;
            switch (action)
            {
                case Enums.Action.Save:
                    text = "Save";
                    break;
                case Enums.Action.Delete:
                    text = "Delete";
                    break;
                case Enums.Action.Forward:
                    text = "Forward";
                    break;
                case Enums.Action.Publish:
                    text = "Publish";
                    break;
                case Enums.Action.UnPublish:
                    text = "Unpublish";
                    break;
                case Enums.Action.Vote:
                    text = "Vote";
                    break;
                case Enums.Action.Register:
                    text = "Register";
                    break;
                case Enums.Action.SignIn:
                    text = "SignIn";
                    break;
                default:
                    text = "Undefined action";
                    break;
            }

            return text;
        }

        public string GetActionResultText(Enums.ActionResult result)
        {
            string text = null;
            switch (result)
            {
                case Enums.ActionResult.Success:
                    text = "Succeeded";
                    break;
                case Enums.ActionResult.Failure:
                    text = "Failed";
                    break;
                case Enums.ActionResult.Exception:
                    text = "Failed";
                    break;
                default:
                    text = "Undefined action result";
                    break;
            }

            return text;
        }

        public string GetAlertMessage(Type modelType, Enums.Action action, Enums.ActionResult result, Exception ex)
        {
            string modelTypeText = GetModelText(modelType);
            string actionText = GetActionText(action);
            string actionResultText = GetActionResultText(result);

            string message = string.Format("{0} {1} {2}.", modelTypeText, actionText, actionResultText);
            if (ex != null)
                message += " Exception message: " + ex.Message;

            return message;
        }

        public string GetAlertMessage(Type modelType, Enums.Action action, Enums.ActionResult result)
        {
            return GetAlertMessage(modelType, action, result, null);
        }
    }
}
